
<title>Add Item Category</title>


<?php    

/*

***************************************
*                                     *
* Copyright 2011 David Matthew Pugh   *
* Contact Info:thebravedave@gmail.com *
*                                     *
***************************************

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

require_once "../services/webservices.php";
require_once "index.php";
require_once("../Pagination.php");
  
   

 
  if(isset($_POST['submit'])) 
  {
    if(isset($_POST['parent_category_id']))
    {
        $parent_category_id = $_POST['parent_category_id'];
    }
    else
    {
        $parent_category_id = "";
    }
    
    $category_name = $_POST['category_name'];
    $description = $_POST['description'];

    $getrequest = new itemcategory();
    $getrequest->category = $category_name;
    $getrequest->description = $description;
   
    $getrequest->parent_category_id = $parent_category_id;
    $getresponse = $getrequest->additemcategory();
    
    $xml = new SimpleXMLElement($getresponse);
    
    $added = $xml->added;
    if($added == 1)
    {
        echo '<br /><b>Category Added</b><br />';
    }
    else
    {
        echo '<br /><b>Category Did Not Add Successfully</b>'; 
    }
  }
 
    
  
?>
      

<br />
<br />
<div class="leftfloatbar">  
<b>Choose what category this falls under.</b>
<br />


<form action="additemcategory.php" method="POST">   
<select name="parent_category_id">
<option value="0">No Parent Category</option>
<?php
 


$getRequest = new itemcategory();
$getResponse = $getRequest->getallitemcategories();

//Loop through returned XML and display all items        
$xml = new SimpleXMLElement($getResponse);

$Item_Count = $xml->Item_Count;

if($Item_Count > 0)
{
       
    foreach ($xml->Item as $eachitem)         
    {
        $category_id = $eachitem->category_id;
        $category = $eachitem->category;            
?>
<option value="<?php echo $category_id;?>"><?php echo $category;?></option>
<?php
    }
}
else
{
?>
<option value="0">No Categories Found.</option>
<?php
}        
?>
</select>
</div>
<br />
<br />
<br />
<br />
<br />



 


<b>Add Category Information:</b>

<br />

<div class="doubleborderrightmargin"> 
<tr>
<b>Category Name:</b>
    <input type="text" id="category_name" name="category_name">
</tr>
<br />

<tr>
<b>Description</b>
    <input type="text" id="description" name="description">
</tr>
<br />



<tr>
    <input type="submit" id="submit" name="submit"  value="Submit Category">
</tr>
</td>
</form>
</div>


  

